'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async more() {
    const sql=`select * from search`
    const res=await this.app.mysql.query(sql)
    //console.log(res);
    this.ctx.body ={res,code:"200"};
  }
  async detail() {
    this.ctx.body = '';
  }
  async getareadata(){
    const cityname = this.ctx.query.city;
    const sql = `SELECT hot, scenic, metro, business, university, periphery, administration, Airport from area where city='${cityname}'`
    const res = await this.app.mysql.query(sql)
    res.forEach(el=>{
      for (const i in el) {
        el[i] = JSON.parse(el[i])
      }
    })
    this.ctx.body = {info:res}
  }

}

module.exports = HomeController;
